<h5><?php echo t('page', 'Edit User Profile'); ?></h5>

<div class="row-fluid">	
	<div class="span12 individual_profile_form_info hide" id="individual_profile_success_info">
		<div class="alert alter-block alert-success">
<!--				<button type="button" class="close" data-dismiss="alert">&times;</button>-->
			<h4>Success</h4>
			<div class="content">User has been saved!</div>
		</div>
	</div>
</div>

<div class="row-fluid">	
	<div class="span12 individual_profile_form_info hide" id="individual_profile_error_info">
		<div class="alert alter-block alert-error">
<!--				<button type="button" class="close" data-dismiss="alert">&times;</button>-->
			<h4>Error</h4>
			<div class="content"></div>
		</div>
	</div>
</div>

<?php $form = $this->beginWidget('CActiveForm', array(
	'id' => 'individual-profile-form',
	'enableClientValidation' => true,
	'clientOptions' => array(
		'validateOnSubmit' => true,
	),
)); ?>
	<?php echo $form->hiddenField($userEditForm, 'id_user'); ?>

	<div class="row-fluid">
		<?php echo $form->textField($userEditForm, 'firstname', array('placeholder' => $userEditForm->getFieldLabel('firstname'), 'class' => 'fields')); ?>
		<?php echo $form->textField($userEditForm, 'lastname', array('placeholder' => $userEditForm->getFieldLabel('lastname'), 'class' => 'fields')); ?>
	</div>
	
	<div class="row-fluid">
		<?php echo $form->textField($userEditForm, 'email', array('placeholder' => $userEditForm->getFieldLabel('email'), 'class' => 'fields')); ?>
		<?php echo $form->textField($userEditForm, 'username', array('placeholder' => $userEditForm->getFieldLabel('username'), 'class' => 'fields')); ?>
	</div>
	
	<div class="row-fluid">
		<?php echo $form->passwordField($userEditForm, 'password', array('placeholder' => $userEditForm->getFieldLabel('password') . '(leave blank if do not change it)', 'class' => 'fields')); ?>
		<?php echo $form->passwordField($userEditForm, 'password_confirm', array('placeholder' => $userEditForm->getFieldLabel('password_confirm') . '(leave blank if do not change it)', 'class' => 'fields')); ?>
	</div>
	
	<div class="row-fluid">
		<?php echo $form->dropDownList($userEditForm, 'id_user_role', $userEditForm->listExistedRoles(), array('placeholder' => $userEditForm->getFieldLabel('id_user_role'), 'class' => 'fields')); ?>
	</div>
	
	<div class="row-fluid buttons">
		<?php echo CHtml::ajaxSubmitButton(
			t('buttons', 'Update User Profile'), 
			app()->createUrl('user/edit'),
			array(
				'type' => 'post',
				'beforeSend' => 'function(){
					$("#individual_profile_submit").button("loading");
				}',
				'success' => 'function(ret){
					$(".individual_profile_form_info").hide();
					$("#individual_profile_submit").button("reset");
					if(ret["result"]){
						$("#individual_profile_success_info").blink();
					}else{
						$("#individual_profile_error_info").blink({
							"beforeCall": function(){
								$("#individual_profile_error_info .content").html("");
								$.each(ret["errors"], function(attrName, error){
									$(error).each(function(k, e){
										var p = $("<p />").addClass("text-error").append(attrName+": "+e);
										$("#individual_profile_error_info .content").append(p);
									});
								});
							}
						});
					}
				}',
				'dataType' => 'json'
			),
			array(
				'id' => 'individual_profile_submit',
				'type' => 'button', 
				'class' => 'btn btn-small btn-primary',
				'data-loading-text' => 'Saving'
			)
		); ?>
	</div>
<?php $this->endWidget(); ?>	
	